private ["_fmt", "_StructuredString", "_StructuredText"];
private ["_moneyIsNegative", "_icIsNegative", "_lcIsNegative"];

#include "StructuredTextConstants.sqf";

if (time < 30) then
{
  // intro
	sleep 2;
  hintSilent format ["Koh Pulau CTI\nOccupation mode\nMade by granQ and Ktotte\nDialogs by Dr Eyeball\nVersion: %1", 
    Mission_version];
  sleep 15;
  //sleep 1;
}
else
{
  hintSilent "Please wait 10 seconds for JIP support";
  sleep 10;
  //sleep 1;
};

/*
#start
Hint format ["%1\nIncome\nTax: %2\nIC: %3\nLC: %4\n\nExpenses \nUpkeep: %5\n\nBalance\nMoney: %6\nIC: %7\nLogistic: %8\n\n\n%9\nIncome\nTax: %10\nIC: %11\nLC: %12\n\nExpenses \nUpkeep: %13\n\nBalance\nMoney: %14\nIC: %15\nLogistic: %16", side0Name, side0_money_income,side0_ic_income,side0_lc_income,side0_upkeep,side0_money,side0_ic,side0_lc,side1Name, side1_money_income,side1_ic_income,side1_lc_income,side1_upkeep,side1_money,side1_ic,side1_lc]
~5
Hint format ["Victory Points\n%1 control: %2\n%3 control: %4\nTotal points: %5", side0Name,side0zones,side1Name,side0zones,maxZones]
~5
goto "loop"
*/

for [{}, {true}, {true}] do
{
  if (showScorehint) then
  {
    //_fmt = "Economy\nMoney: %6 (%2)\nIndustrial: %7 (%3)\nLogistic: %8 (%4)\n\nExpenses \nMoney/Logistic: %5 / %9"
    if (side player == side0) then 
    {  
      _moneyIsNegative = (side0_money_income - side0_upkeep) <= 0;      
      _icIsNegative = side0_ic_income <= 0;
      _lcIsNegative = (side0_money_income - side0_upkeep) < 0;
    };
    if (side player == side1) then 
    {  
      _moneyIsNegative = (side1_money_income - side1_upkeep) <= 0;
      _icIsNegative = side1_ic_income <= 0;
      _lcIsNegative = (side1_money_income - side1_upkeep) < 0;
    };

    _moneyIsNegativeColor = if (_moneyIsNegative) then {'%15'} else {'%14'};
    _icIsNegativeColor = if (_icIsNegative) then {'%15'} else {'%14'};
    _lcIsNegativeColor = if (_lcIsNegative) then {'%15'} else {'%14'};
    
    _fmt = format[
      "%14Economy%12 %13"+
      "%10Money:%12%11 %6 ("+_moneyIsNegativeColor+"%2%12) %12%13"+
      "%10Industrial:%12%11 %7 ("+_icIsNegativeColor+"%3%12) %12%13"+
      "%10Logistic:%12%11 %8 ("+_lcIsNegativeColor+"%4%12) %12%13"+
      "%13"+
      "%14Expenses%12 %13"+
      "%10Money/Logistic:%12 %11%5 / %9%12",
      
      "%1", "%2", "%3", "%4", "%5", "%6", "%7", "%8", "%9", 
      _ST_color_Aqua, // %10
      _ST_color_white, // %11
      _ST_text_normal, // %12
      _ST_linebreak, // %13
      _ST_color_Lime, // %14
      _ST_color_Red // %15
      
      ];

    if (side player == side0) then 
    {  
      _StructuredString = format [_fmt, 
        side0Name, 
        (side0_money_income - side0_upkeep),
        side0_ic_income,
        (side0_lc_income - side0_lc_upkeep),
        side0_upkeep,
        round(side0_money),
        round(side0_ic),
        round(side0_lc),
        side0_lc_upkeep
      ];
    };
    if (side player == side1) then 
    {  
      _StructuredString = format [_fmt, 
        side1Name, 
        (side1_money_income - side1_upkeep),
        side1_ic_income,
        (side1_lc_income - side1_lc_upkeep),
        side1_upkeep,
        side1_money,
        side1_ic,
        side1_lc,
        side1_lc_upkeep
      ];
    };
    _StructuredText = parseText _StructuredString;
    hintSilent _StructuredText;
  };
  
  sleep 5;
};
